{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
        margin-left: 3.333px;
    }

    .search {
        margin-bottom: 0px !important;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }

</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='type' value='3'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('index',['type'=>3])}{present name='shenhe'}/shenhe/{$shenhe}{/present}">视频</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='type' value='4'}asdlkjasd{/eq}{/present}" href="{:url('index',['type'=>4])}{present name='shenhe'}/shenhe/{$shenhe}{/present}">图集</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('index',['shenhe'=>1])}{present name='type'}/type/{$type}{/present}">通过</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='0'}asdlkjasd{/eq}{/present}" href="{:url('index',['shenhe'=>0])}{present name='type'}/type/{$type}{/present}">审核</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('index',['shenhe'=>-1])}{present name='type'}/type/{$type}{/present}">拒绝</a>
                    </div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="">
                            <div class="pull-left search">
                             <!--    <div class="columns columns-right btn-group pull-left" >
                                    <select class="form-control" name="where">
                                        <option value="">全部</option>
                                        <option value="id">文章ID</option>
                                    </select>
                                </div> -->
                                <div class="columns columns-right btn-group pull-left" >
                                </div>
                                {php}
                                if(input('?param.search_typeid') || input('?param.search_name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('index')}">返回管理</a>
                                </div>{php}
                                }
                                {/php}
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" id="filter" type="text"
{php}
if(input('?param.search_name')){
            if(input('param.search_name')){
               echo "value='".input('search_name')."'";
            } 
        }
{/php}
                                     name="search_name" placeholder="输入标题搜索">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                  <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">管理</th>
                                    <!--<th>分类</th>-->
                                    <th data-align="center">用户</th>
                                    <th>内容</th>
                                    {eq name='type' value='3'}
                                        <th data-align="center">视频</th>
                                    {/eq}
                                    <th data-align="center">时间</th>
                                    <th data-align="center">状态</th>
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.dy_id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.dy_id}"></td>
                                    <td id="id">{$v.dy_id}</td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <li><a onclick="add('{:url('add',['id'=>$v.dy_id,'url'=>-1,'type'=>$v.type])}')">修改</a></li>
                                                <li class="divider"></li>
                                                <li><a onclick="add('{:url('comment',['id'=>$v.dy_id,'url'=>-1])}')">评论</a></li>
                                                <li class="divider"></li>
                                                {switch name="$v.shenhe"}
                                                {case value="-1"}
                                                <li><a onClick="shenhe({$v.dy_id},'0')">审核</a></li>
                                                <li><a onClick="shenhe({$v.dy_id},'1')"><span style="color: #1ab394; ">通过</span></a></li>
                                                {/case}
                                                {case value="0"}
                                                <li><a onClick="shenhe({$v.dy_id},'1')"><span style="color: #1ab394; ">通过</span></a></li>
                                                <li><a onClick="shenhe({$v.dy_id},'-1')"><span style="color: #ed5565; ">拒绝</span></a></li>
                                                {/case}
                                                {case value="1"}
                                                <li><a onClick="shenhe({$v.dy_id},'-1')"><span style="color: #ed5565; ">拒绝</span></a></li>
                                                <li><a onClick="shenhe({$v.dy_id},'0')">审核</a></li>
                                                {/case}
                                                {/switch}
                                                <li class="divider"></li>
                                                <li><a onclick="del({$v.dy_id})">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>

                                    <!--<td>{$v.name}</td>-->
                                    <td >
                                        {if condition="$v.type==2"}系统{else /}
                                        <a onclick="member('{$v.userid}')" style="color:#40BCF7">{$v.username}</a><br/>{if condition='$v.phone'}({$v.phone}){/if}
                                        {/if}
                                    </td>
                                    <td id="title">
                                        <a onclick="watch('{$v.dy_id}')">
                                    <?php echo _substr($v['content']); ?>
                                    {notempty name="v.masterimg"}
                                        <span class="label label-primary">图</span>
                                    {/notempty}
                                    </td>
                                    {eq name='type' value='3'}
                                        <td>
                                            <a href="__ROOT__{$v.video}" target="_blank">
                                                <video src="__ROOT__{$v.video}" volume="0.5" poster="__ROOT__{$v.cover}" controls preload="true" playsinline webkit-playsinline="webkit-playsinline" x-webkit-airplay="allow" style="max-width:200px">您的浏览器不支持播放本视频</video>
                                            </a>
                                        </td>
                                    {/eq}
                                    <td> 
                                        <span {php}if(date('Y-m-d H:i:s')==$v['addtime'])echo 'style="color: #ed5565"';{/php}>{$v.addtime}</span>
                                    </td>
                                    <td id="hide{$v.dy_id}">{if condition="$v.shenhe eq '0'"}<span class="btn btn-default btn-xs">审 核</span>{elseif condition="$v.shenhe eq '1'" /}<span class="btn btn-primary btn-xs">通 过</span>{elseif condition="$v.shenhe eq '-1'" /}<span class="btn btn-primary btn-xs" style="background-color: #414141;border-color:#414141">拒 绝</span>{/if}</td>
                                </tr>
                                {/volist}
                            </tbody>                          

                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
               <div class="col-sm-6">
                    <div  class="btn btn-outline btn-default" onclick="alla(1)">
                        批量通过
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(-1)">
                        批量拒绝
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(0)">
                        批量审核
                    </div>
                    <a href="?order=1" type="button" class="btn btn-outline btn-default">
                        倒序排序
                    </a>
                    <a href="?order=2" type="button" class="btn btn-outline btn-default">
                        顺序排序
                    </a>
                    <div  class="btn btn-outline btn-default" onclick="alla('del')">
                        批量删除
                    </div>
                    
                </div> 
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
$(document).ready(function(){
    $('#desAll').click(function(){
        var des=$(".form-horizontal").serialize();
        ajaxFun("post",'{:url('article/desAll')}',des,'json',function(ret){
            if(ret){
                if(ret.ret){
                    self.location.reload();
                }else{
                    layer.msg(ret.err)
                }
            }else{
                swal_msg("错误",ret,"error");
            }
        })
    })
     
    $('#delidAll').click(function(){
        $('input[type=checkbox]').each(function(){
            var self=$(this);
            if(!self.prop('checked')){
                self.prop('checked',true);
            }else{
                self.prop('checked',false);
            }
        });
    })
});
function del(id){
    swal_del(id,"{:url('del')}")
}
function alla(types){
    var all=$(".form-horizontal").serialize();
    var alls=$(".form-horizontal").serializeArray();
   console.log(JSON.stringify(alls))

    ajaxFun("post",'{:url('article/shenheAll')}?type='+types,all,'json',function(ret){
        
        if(ret){
            var text
            switch(types)
            {
            case -1:
              text = '<span class="btn btn-primary btn-xs" style="background-color: #414141;border-color:#414141">拒 绝</span>';
              break;
            case 0:
              text = '<span class="btn btn-default btn-xs">审 核</span>';
              break;
            case 1:
              text = '<span class="btn btn-primary btn-xs">通 过</span>';
              break;
            }
            for(var i=0;i<alls.length;i++){
                if(types=='del'){
                    $('#id'+alls[i]['value']).remove();
                }else{
                    $('#hide'+alls[i]['value']).html(text);
                }
            }
             
            swal_msg('操作成功')
        }
    })
     
}
function watch(id) {
    layui.use('layer', function(){
      var layer = layui.layer;
      layer.open({
          title :'预览',
          area: ['100%', '100%'],
          type: 2,
          content: '{:url('article/watch')}?id='+id // //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
        });


    });
}

function shenhe(id,value){
    ajaxFun("post","{:url('authadd')}",{id:id,shenhe:value},'json',function(ret){
        if(ret){
            if(ret.ret){
                layer.msg(ret.ret)
                /*$("#id"+id).hide('fast',function(){
                     $("#id"+id).remove();
                })*/
                window.location.reload()
            }else{
                layer.msg(ret.err)
            }
        }else{
            swal_msg("错误",ret,"error");
        }
    })
}

function member(id)
{
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("member/index")}?search=id&name='+id
        });
    });
}
</script>
 